function setHeight() {
  var setHeightDoms = document.getElementsByClassName('setHeight')

  setHeightDoms = Array.prototype.slice.call(setHeightDoms, 0)

  for (var i in setHeightDoms) {
    ;(function(idx) {
      var image = new Image()
      var bg =
        (setHeightDoms[idx].style &&
          setHeightDoms[idx].style.backgroundImage) ||
        '';
      bg = bg.replace(/"|'/g, '');
      var bgsrc = bg.slice(4, -1);

      if (image.naturalHeight) {
        setHeightDoms[idx].style.height = image.naturalHeight + 'px';
      } else {
        image.onload = function() {
          setHeightDoms[idx].style.height = this.height + 'px';
        }
      }

      image.src = bgsrc
    })(i)
  }
}

setHeight()
